package com.jastar.android.test.base;

import android.os.Bundle;
import android.view.View;

import androidx.appcompat.app.AppCompatActivity;

import com.jastar.android.test.R;

/** 图形图像 */
public class DrawableShapeActivity extends AppCompatActivity implements View.OnClickListener {

    private boolean isRect;

    private View view_shape;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_drawable_shape);

        isRect = true;
        view_shape = findViewById(R.id.view_shape);
        view_shape.setBackgroundResource(R.drawable.view_shape_rect);
        view_shape.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.view_shape) {
            if (isRect) {
                view_shape.setBackgroundResource(R.drawable.view_shape_oval);
                isRect = false;
            } else {
                view_shape.setBackgroundResource(R.drawable.view_shape_rect);
                isRect = true;
            }
        }
    }

}